package tr.edu.metu.is.mega.common.dto;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * Data structure class for teams.
 * 
 */
public class TeamDTO extends BaseDTO {

    private static final long serialVersionUID = -8903269286941389874L;

    public static final String FIELD_LOGO = "logo";

    public static final String FIELD_TEAM_NAME = "teamName";

    public static final String FIELD_MEMBERS = "members";

    public static final String FIELD_MEMBERS_LIST = "membersList";

    private String logo;

    @NotNull
    @Size(max = 50)
    private String teamName;

    private CourseDTO course;

    private List<CourseStudentDTO> members;

    /**
     * Default constructor.
     */
    public TeamDTO() {
        members = new ArrayList<CourseStudentDTO>(4);
    }

    /**
     * Default constructor.
     * 
     * @param course course of team
     */
    public TeamDTO(CourseDTO course) {
        this.course = course;
    }

    /**
     * Returns logo.
     * 
     * @return the logo
     */
    public String getLogo() {
        return logo;
    }

    /**
     * Sets logo value.
     * 
     * @param logo the logo to set
     */
    public void setLogo(String logo) {
        this.logo = logo;
    }

    /**
     * Returns teamName.
     * 
     * @return the teamName
     */
    public String getTeamName() {
        return teamName;
    }

    /**
     * Sets teamName value.
     * 
     * @param teamName the teamName to set
     */
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    /**
     * Returns course.
     * 
     * @return the course
     */
    public CourseDTO getCourse() {
        return course;
    }

    /**
     * Sets course value.
     * 
     * @param course the course to set
     */
    public void setCourse(CourseDTO course) {
        this.course = course;
    }

    /**
     * Returns members.
     * 
     * @return the members
     */
    public List<CourseStudentDTO> getMembers() {
        return members;
    }

    /**
     * Sets members value.
     * 
     * @param members the members to set
     */
    public void setMembers(List<CourseStudentDTO> members) {
        this.members = members;
    }

    /**
     * Returns members.
     * 
     * @return the members
     */
    public String getMembersList() {
        StringBuilder sb = new StringBuilder();
        for (CourseStudentDTO dto : members) {
            sb.append(dto.getUser().getFullName()).append(",");
        }
        return sb.toString();
    }

}
